<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.*" %>
<%@ page import="org.tigr.htc.persist.*" %>
<%@ page import="org.tigr.htc.common.*" %>
<%@ page import="org.tigr.htc.cmd.*" %>
<!-- <%@ page import="org.tigr.antware.shared.command.events.*" %> -->


<%!
    static String[] colors = new String[] { "#ececec", "#dc9000" };
%>
<%
String eventType = request.getParameter("eventType");
%>

<html>
<head>
</head>
<body>
<%
    if(eventType != null) {
	out.println(" event Type " + eventType);
	IPersist pl = PersistFactory.getIPersist();
	long id;
	Command cmd;

	String sid = request.getParameter("id");

	if(sid != null) { // display default page
	    id = Long.parseLong(sid);
	    cmd = (Command) pl.find(id, Command.class);

	    String message = request.getParameter("message");
	    String machine = request.getParameter("machine");
	    String user = request.getParameter("user");
	    String logLocation = request.getParameter("logLocation");
	    String rv = request.getParameter("returnValue");

	    out.println(message + "<BR>");
	    out.println(machine + "<BR>");
	    out.println(logLocation + "<BR>");

	if(eventType.equals("submit")) {
	    out.println("\t fire submit event");
	    cmd.taskSubmitted(machine, logLocation);
	} else if(eventType.equals("start")) {
            out.println("\t fire start event");
	    cmd.taskStarted(message, new Date(), machine, 0, 0);
	} else if(eventType.equals("finish")) {
            out.println("\t create finish event");
	    cmd.taskFinished(message, new Date(), Integer.parseInt(rv), 0);
	} else if(eventType.equals("failure")) {
            out.println("\t create failure event");
	    cmd.taskFailure(new Exception(message), 0);
	}
	    
	}
    }
%>

<form method="get" action="request_events.jsp">
  Create Event for request:
  <table border=1 cellspacing=0 cellpadding=3 >
    <tr><td>Command ID</td>
	<td>Message</td>
	<td>log location</td>
	<td>user</td>
	<td>machine</td>
	<td>returnValue</td>
    </tr>
    <tr><td><input type="text" name="id" value=""/></td>
	<td><input type="text" name="message" value=""/></td>
	<td><input type="text" name="logLocation" value=""/></td>
	<td><input type="text" name="user" value=""/></td>
	<td><input type="text" name="machine" value=""/></td>
	<td><input type="text" name="returnValue" value=""/></td>
    </tr>
  </table>
<br>
<select name="eventType">
<option value="submit"> submit</option>
<option value="start"> start</option>
<option value="finish"> finish</option>
<option value="failure"> failure</option>
</select>&nbsp;<br>
<input type="submit" value="Send Event" />
</form>
<br>
<hr>
tigr copyright notice here

</body>
</html>
